// pages/artDeatil/artDetail.js
const {artDetail,artCollect} = require("../../models/article")
Page({
  data: {
    result:""
  },
  onLoad: function (options) {
    var {id} = options
    this.getHttp(id)
  },
  getHttp(id){
    artDetail(id).then(res=>{
      var result = res.data.data[0]
      this.setData({
        result
      })
    })
  },
  handleCollect(event){
    var result = this.data.result
    result.collected = !result.collected
    var collected = result.collected
    var {id} = event.currentTarget.dataset
    artCollect({id,collected})
    this.setData({
      result
    })
  }
})